package com.example.mountainwalker.controller;

import com.example.mountainwalker.entity.GroupTourFavoriteInfo;
import com.example.mountainwalker.service.GroupTourFavoriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/mw")
@CrossOrigin
public class GroupTourFavoriteController {

    @Autowired
    private GroupTourFavoriteService groupTourFavoriteService;

    //http://localhost:8080/stu/list
    @GetMapping("/GroupTourFavoriteList")
    public List<GroupTourFavoriteInfo> getgroupTourFavoriteList() {
        List<GroupTourFavoriteInfo> GroupTourFavoriteInfo = groupTourFavoriteService.getGroupTourFavorite();
        return GroupTourFavoriteInfo;
    }

    // http://localhost:8080/stu/find?id=222
    @GetMapping("/GroupTourFavoriteById")
    public GroupTourFavoriteInfo  getGroupTourFavoriteById(Integer id) {
        GroupTourFavoriteInfo  groupTourFavorite = groupTourFavoriteService.getGroupTourFavoriteById(id);
        return groupTourFavorite;
    }

    // http://localhost:8080/mw/deleteGroupTourFavoriteById?id=2
    @GetMapping("/deleteGroupTourFavoriteById")
    public int deleteGroupTourFavoriteById(Integer id) {
        int result = groupTourFavoriteService.deleteGroupTourFavoriteById(id);
        return result;
    }
    // http://localhost:8080/mw/addGroupTourFavorite
    @PostMapping("/addGroupTourFavorite")
    public int addGroupTourFavorite(@RequestBody GroupTourFavoriteInfo groupTourFavoriteInfo) {
        return groupTourFavoriteService.addGroupTourFavorite(groupTourFavoriteInfo);
    }

    // http://localhost:8080/mw/updateGroupTourFavorite
    @PutMapping("/updateGroupTourFavorite")
    public int updateGroupTourFavorite(@RequestBody GroupTourFavoriteInfo groupTourFavoriteInfo) {
        return groupTourFavoriteService.updateGroupTourFavorite(groupTourFavoriteInfo);
    }

}


